home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Winamp 2.77 i 3.0beta / wasabi-sdk_beta1.exe / studio / Example1 / example1wnd.h < prev    next >
C/C++ Source or Header  |  2001-10-08  |  4KB  |  108 lines

  1. /*
  2.  
  3.   Nullsoft WASABI Source File License
  4.  
  5.   Copyright 1999-2001 Nullsoft, Inc.
  6.  
  7.     This software is provided 'as-is', without any express or implied
  8.     warranty.  In no event will the authors be held liable for any damages
  9.     arising from the use of this software.
  10.  
  11.     Permission is granted to anyone to use this software for any purpose,
  12.     including commercial applications, and to alter it and redistribute it
  13.     freely, subject to the following restrictions:
  14.  
  15.     1. The origin of this software must not be misrepresented; you must not
  16.        claim that you wrote the original software. If you use this software
  17.        in a product, an acknowledgment in the product documentation would be
  18.        appreciated but is not required.
  19.     2. Altered source versions must be plainly marked as such, and must not be
  20.        misrepresented as being the original software.
  21.     3. This notice may not be removed or altered from any source distribution.
  22.  
  23.  
  24.   Brennan Underwood
  25.   brennan@nullsoft.com
  26.  
  27. */
  28.  
  29. #ifndef _EXAMPLE1WND_H
  30. #define _EXAMPLE1WND_H
  31.  
  32. #include "../common/virtualwnd.h"
  33. #include "../common/SimpleWndCreate.h"
  34. #include "../common/nsGUID.h"
  35.  
  36. #define EXAMPLE1WND_PARENT VirtualWnd
  37. //
  38. // Well, great.  Now that we have that whole "PARENT" thing straightened out,
  39. // let's define the class we're going to be using in our first happy example.
  40. class Example1Wnd : public EXAMPLE1WND_PARENT {
  41.  
  42. public:
  43.     // This public enum allows us to decide at runtime if the object that we're
  44.     // instantiating will paint itself in a boring or exciting manner.
  45.     typedef enum {
  46.         BORING,
  47.         EXCITING
  48.     }    BlitStyle;
  49.  
  50. public:
  51.     // And make a pair of constructors that let us set the default blitstyle value
  52.     // Or specify it upon allocation & construction.        
  53.     Example1Wnd( BlitStyle style = BORING ) :
  54.         myBlitStyle( style ),
  55.         EXAMPLE1WND_PARENT() {    }
  56.         
  57.     // And, then, here are the virtual methods we'll be overriding to get our
  58.     // little window to be painting prettily on its little canvas.  Woot!
  59.   virtual int onPaint(Canvas *canvas);
  60.     virtual void timerCallback(int id);
  61.     virtual int onInit();
  62.     // We'll cover these methods as we implement them in the CPP file.
  63.  
  64.  
  65.  
  66.   // =========================================================================
  67.   //
  68.   //    These static methods must be provided in order to use this object
  69.   //  as a WindowCreationObject in the SimpleWndCreate template.  The ExampleB
  70.   //  project shows a way to implement these statics upon your component obj.
  71.   //
  72.   //    In this example, we're implementing these methods on this window class
  73.   //  itself.  Furthermore, because we reuse this Example1 window class IN
  74.   //  ExampleB, we cannot assume a single instance of this object to ever be
  75.   //  resident (and thus cannot use the "Main()" method implemented on the
  76.   //  ExampleB component to thunk from a static call to the single instance).
  77.   //
  78.   //  Complicated, eh?
  79.   //
  80.   //    Well, not really... just the slightly-more-complicated version living
  81.   //  in the earlier project rather than the later one.  Sorry.
  82.   //
  83.   static const char *getWindowNameStatic(); 
  84.   static GUID getGUIDStatic();
  85.   static RootWnd *createWindowStatic(int n, RootWnd *parentWnd);
  86.   static int destroyWindowStatic(RootWnd *deadWnd);
  87.   static ThingerBitmapInfo getThingerBitmapInfoStatic();
  88.   // =========================================================================
  89.  
  90.     static BlitStyle            getNextBlitStyle();
  91.  
  92. protected:
  93.     // How did I want to draw myself today?
  94.     BlitStyle                    myBlitStyle;
  95.   // There's nothing quite as useless as code that displays how to implement
  96.   // the functionality of "Look different the next time you're opened" !!
  97.     static BlitStyle            nextBlitStyle;
  98.  
  99.   // I assign a GUID to this window class, to allow it to be accessible
  100.   // through the window creation services.
  101.   static GUID myWindowClassGUID;
  102.   // And here we're just going to write down what pointers we created, in
  103.   // order to ensure that we delete them and only them.
  104.   static PtrList< Example1Wnd > createdWindows;
  105. };
  106.  
  107. #endif _EXAMPLE1WND_H
  108.